package world;

import math.Matrix4;
import sys.SysParam;
import coord.Coordinator;

public class WorldManager {
	public static WorldManager get() {
		if (instance == null) {
			instance = new WorldManager();
			instance.init();
		}
		return instance;
	}

	public void renderCrosshair() {
		crosshair.render();
	}

	public void loadWorld() {
		world.load();
	}

	public void renderWorld() {
		world.render();
	}

	public  Matrix4 getWorldMatix() {
		return world.matixStack.getTop();
	}

	public Camera getCamera() {
		return camera;
	}

	public void renderCoordinator() {
		coordinator.render();
	}

	// ----------------------------------------------------------------private
	private static WorldManager instance;
	private World world;
	private Camera camera;
	private Crosshair crosshair;
	private Coordinator coordinator;


	private WorldManager() {
	}

	private void init() {
		crosshair = new Crosshair();
		world = new World();
		camera = new Camera(SysParam.FOV, SysParam.SCREEN_WIDTH, SysParam.SCREEN_HEIGHT, SysParam.ZNEAR, SysParam.ZFAR);
		world.addCamera(camera, SysParam.PlAYER_INIT_POSTION, SysParam.PlAYER_INIT_ORIENTATION);
		coordinator = new Coordinator();
	}
}
